﻿@using DualControl.CommonServices
@using DualControl.RiskPoints.Dtos

@model Abp.Application.Services.Dto.ListResultDto<RiskPointListDto>
@using X.PagedList.Mvc.Core; @*import this so we get our HTML Helper*@
@using X.PagedList; @*import this so we can cast our list to IPagedList (only necessary because ViewBag is dynamic)*@

@inject ICommonService CommonService

@{
    ViewData["Title"] = "危险因素管理";
}

@section scripts
    {
    <environment names="Development">
        <script src="~/view-resources/Views/RiskFactors/RiskFactor.js" asp-append-version="true"></script>
    </environment>
    <environment names="Staging,Production">
        <script src="~/view-resources/Views/RiskFactors/RiskFactor.min.js" asp-append-version="true"></script>
    </environment>
}
<style>
    .table tbody tr td {
        vertical-align: middle;
    }
</style>

<div class="row clearfix">
    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
        <div class="card">
            <div class="header">
                <h2>
                    @L("RiskFactor")
                </h2>
                <ul class="header-dropdown m-r--5">
                    <li class="dropdown">
                        <a href="javascript:void(0);" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
                            <i class="material-icons">more_vert</i>
                        </a>
                        <ul class="dropdown-menu pull-right">
                            <li><a id="RefreshButton" href="javascript:void(0);" class="waves-effect waves-block"><i class="material-icons">refresh</i>@L("Refresh")</a></li>
                        </ul>
                    </li>
                </ul>
            </div>
            <div class="body table-responsive">
                @foreach (var riskpoint in ViewBag.PageOfRiskPointListDto)
                {
                    <div class="panel panel-primary">
                        <div class="panel-heading">
                            <h3 class="panel-title">
                                风险点编码：@riskpoint.Code &nbsp; 车间/班组：@CommonService.GetOrganizationUnits().SingleOrDefault(c => c.Key == riskpoint.OrganizationUnitId).Value   &nbsp; 区域/工段   @riskpoint.AreaOrSection&nbsp; 风险点名称：@riskpoint.Name
                                &nbsp;

                            </h3>
                        </div>
                        <table class="table">
                            <tr><th>序号</th><th>作业步骤</th><th>危险因素</th><th>导致事故类型</th><th>岗位</th><th>操作</th></tr>
                            @{ if (riskpoint.HazardSources.Count > 0)
                                {
                                    int i = 0;
                                    @foreach (var hazardsource in riskpoint.HazardSources)
                                    {
                                        i++;
                                        <tr>
                                            <td width="5%">@i.</td>
                                            <td>@hazardsource.HazardSourceName</td>
                                            <td>@hazardsource.RiskFactor  </td>
                                            <td>                                              
                                          @{
                                                    string space = " ";
                                                    if (hazardsource.AccidentTypesForView != null)
                                                    {
                                                        foreach (var accident in hazardsource.AccidentTypesForView)
                                                        {
                                                            @accident
                                                            @space
                                                        }
                                                    }
                                                }

                                            </td>
                                            <td>
                                                @CommonService.GetPosts().SingleOrDefault(c => c.Key == hazardsource.PostId).Value
                                            </td>
                                            <td>
           <span class="glyphicon glyphicon-pencil"></span>
  <button class="edit-hazardsource" data-hazardsource-id="@hazardsource.Id" data-toggle="modal" data-target="#RiskFactorEditModal">编辑</button>
                                            </td>
                                        </tr>
                                    }
                                }
                            }
                        </table>
                    </div>
                }

            </div>
        </div>
    </div>
</div>

@Html.PagedListPager((IPagedList)ViewBag.PageOfRiskPointListDto, page => Url.Action("Index", new { page }))

<div class="modal fade" id="RiskFactorEditModal" tabindex="-1" role="dialog" aria-labelledby="HazardSourceCreateModalLabel" data-backdrop="static">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
           
            <div class="modal-body">
                <form name="RiskFactorEditForm222" role="form" novalidate class="form-validation">
                         
                </form>
            </div>
        </div>
    </div>
</div>
